<?php
/*
 * @package AJAX_Chat
 * @author Sebastian Tschan
 * @copyright (c) Sebastian Tschan
 * @license GNU Affero General Public License
 * @link https://blueimp.net/ajax/
 */

require_once($_SERVER["DOCUMENT_ROOT"]."/modules/base_mod.php");
// List containing the registered chat users:
$users = array();
$users[0] = array();
$users[0]['userRole'] = AJAX_CHAT_GUEST;
$users[0]['userName'] = null;
$users[0]['password'] = null;
$users[0]['channels'] = array(0);

$conn = BaseMod::getConnection();
$sql = "select pid, name, password, chat_level from account where pid > 0 order by pid";
$result = mysql_query($sql, $conn);

while($row = mysql_fetch_assoc($result)){
    $userId = $row["pid"];
    $userName = $row["name"];
    $userPass = $row["password"];
    $adminLevel = $row["chat_level"];
    $users[$userId] = array();
    switch ($adminLevel){
        case 0:
                $users[$userId]['userRole'] = AJAX_CHAT_GUEST;
                break;
        case 1:
                $users[$userId]['userRole'] = AJAX_CHAT_USER;
                break;
        case 2:
                $users[$userId]['userRole'] = AJAX_CHAT_MODERATOR;
                break;
        case 3:
                $users[$userId]['userRole'] = AJAX_CHAT_ADMIN;
                break;
        default:
                $users[$userId]['userRole'] = AJAX_CHAT_GUEST;
                break;
    } // end switch
    $users[$userId]['userName'] = strtolower($userName);
    $users[$userId]['password'] = $userPass;
    $sql = "select chat_id from ajax_chat_channel_users where pilot_id = ".$userId." order by chat_id";
    $channels = mysql_query($sql, $conn);
    $users[$userId]['channels'] = array();
    while($chn = mysql_fetch_assoc($channels)){
        $users[$userId]['channels'][] = $chn["chat_id"];
    }
    //$users[$userId]['channels'] = array(0,1);
} // end while
//// Default guest user (don't delete this one):

//
//// Sample admin user:
//$users[11] = array();
//$users[11]['userRole'] = AJAX_CHAT_ADMIN;
//$users[11]['userName'] = 'webxro';
//$users[11]['password'] = 'thisisweb';
//$users[11]['channels'] = array(0,1);
//
//$users[13] = array();
//$users[13]['userRole'] = AJAX_CHAT_ADMIN;
//$users[13]['userName'] = 'jirina';
//$users[13]['password'] = 'pAy6chaZ';
//$users[13]['channels'] = array(0,1);
//
//$users[14] = array();
//$users[14]['userRole'] = AJAX_CHAT_ADMIN;
//$users[14]['userName'] = 'carolus_rex';
//$users[14]['password'] = 'cUJ66asw';
//$users[14]['channels'] = array(0,1);
//
//
//
//$users[21] = array();
//$users[21]['userRole'] = AJAX_CHAT_MODERATOR;
//$users[21]['userName'] = 'Bocaj';
//$users[21]['password'] = 'Pu6PuCru';
//$users[21]['channels'] = array(0,1);
//
//
//
//$users[22] = array();
//$users[22]['userRole'] = AJAX_CHAT_MODERATOR;
//$users[22]['userName'] = 'Sidsnake';
//$users[22]['password'] = 'R7PHep2U';
//$users[22]['channels'] = array(0,1);
//
//
//$users[23] = array();
//$users[23]['userRole'] = AJAX_CHAT_MODERATOR;
//$users[23]['userName'] = 'Serkses';
//$users[23]['password'] = '6AkutHAz';
//$users[23]['channels'] = array(0,1);
//
//$users[24] = array();
//$users[24]['userRole'] = AJAX_CHAT_MODERATOR;
//$users[24]['userName'] = 'Black Birdy';
//$users[24]['password'] = 'SPam6n';
//$users[24]['channels'] = array(0,1);
//
//$users[301] = array();
//$users[301]['userRole'] = AJAX_CHAT_USER;
//$users[301]['userName'] = 'kilmore';
//$users[301]['password'] = 'HEm2ku';
//$users[301]['channels'] = array(0,1);
//
//$users[302] = array();
//$users[302]['userRole'] = AJAX_CHAT_USER;
//$users[302]['userName'] = 'pyrosee';
//$users[302]['password'] = 'HEm2ku';
//$users[302]['channels'] = array(0,1);
//
//
//
//// Sample moderator user:
//$users[2] = array();
//$users[2]['userRole'] = AJAX_CHAT_MODERATOR;
//$users[2]['userName'] = 'moderator';
//$users[2]['password'] = 'm42wrf4 dsty 4';
//$users[2]['channels'] = array(0);
//
//// Sample registered user:
//$users[3] = array();
//$users[3]['userRole'] = AJAX_CHAT_USER;
//$users[3]['userName'] = 'user';
//$users[3]['password'] = 'wgfe jfudas43 rf4';
//$users[3]['channels'] = array(0);
//
?>